package com.helloandroid.paso.ui.multimedia;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.helloandroid.paso.R;

public class SpecialAdapterVideolist extends SimpleAdapter {
	private LayoutInflater mInflater;
	private ArrayList<HashMap<String, String>> items;

	public SpecialAdapterVideolist(Context context, ArrayList<HashMap<String, String>> items, int header, String[] strings, int[] is) {
		super(context, items, header, strings, is);
		// Cache the LayoutInflate to avoid asking for a new one each time.
		this.items = items;
		mInflater = LayoutInflater.from(context);
	}

	static class ViewHolder {
		TextView title;
	}

	/**
	 * Make a view to hold each row.
	 * 
	 * @see android.widget.ListAdapter#getView(int, android.view.View,
	 *      android.view.ViewGroup)
	 */
	public View getView(int position, View convertView, ViewGroup parent) {

		// A ViewHolder keeps references to children views to avoid unneccessary
		// calls
		// to findViewById() on each row.
		ViewHolder holder;

		// When convertView is not null, we can reuse it directly, there is no
		// need
		// to reinflate it. We only inflate a new View when the convertView
		// supplied
		// by ListView is null.
		if (convertView == null) { // ||
			// convertView.getTag().toString().compareTo("divider")
			// == 0) {
			convertView = mInflater.inflate(R.layout.multimedialistviewitem, null);

			// Creates a ViewHolder and store references to the two children
			// views
			// we want to bind data to.
			holder = new ViewHolder();
			holder.title = (TextView) convertView.findViewById(R.id.multimedialistviewitem_textView);

			convertView.setTag(holder);
		} else {
			// Get the ViewHolder back to get fast access to the TextView
			// and the ImageView.
			holder = (ViewHolder) convertView.getTag();
		}

		holder.title.setText(items.get(position).get("title"));
		
		return convertView;
	}
}